﻿using System.IO;
using UnityEditor;
using UnityEngine;

[InitializeOnLoad]
public class FolderMenu
{
    private static string projectRootFolder;
    private static int num = 0;

    static FolderMenu()
    {
        projectRootFolder = new DirectoryInfo(Application.dataPath).Parent.Parent.FullName;
    }

    [MenuItem("常用文件夹/打开配置目录")]
    private static void OpenDataTableForlder()
    {
        string path = Path.Combine(projectRootFolder, "cfgs", "Datas");
        Application.OpenURL(path);
    }

    [MenuItem("常用文件夹/截图")]
    private static void Jietu()
    {
        Texture2D mTexture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
        mTexture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
        mTexture.Apply();
        byte[] bytes = mTexture.EncodeToPNG();
        System.IO.File.WriteAllBytes(Application.dataPath + "/../../shot.png", bytes);
    }
}